<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>企业认证</title>
    <link rel="stylesheet" href="../../../public/dist/css/layui.css">
    <link rel="stylesheet" href="../../../css/enterprisecertification.css">
    <link rel="stylesheet" href="../../../public/font/iconfont.css">
</head>
<style>
    .select-item-text {
        width: 140px;
    }
    .layui-input{
        height: 25px;
    }
</style>

<body>
    <form class="layui-form" action="">
        <div class="container">
            <div class="header">
                <!-- <div class="header-line">
                    <div class="header-icon">
                        <i class="layui-icon " style="font-size: 38px; color: #fff;"></i>
                    </div>
                    <div class="line"></div>
                    <div class="header-icon">
                        <i class="layui-icon  " style="font-size: 38px; color: #fff;"></i>
                    </div>
                    <div class="line"></div>
                    <div class="header-icon">
                        <i class="layui-icon " style="font-size: 38px; color: #fff;"></i>
                    </div>
                </div> -->

                <div class="header-content">

                    <div class="header-content-item">
                        <div class="header-content-txt">营业执照</div>
                        <div class="header-content-btn" id="ok1">未录入</div>
                    </div>
                    <div class="header-content-item">
                        <div class="header-content-txt">法人身份证</div>
                        <div class="header-content-btn" id="ok2">未录入</div>
                    </div>
                    <div class="header-content-item">
                        <div class="header-content-txt">授权书认证</div>
                        <div class="header-content-btn" id="ok3">未录入</div>
                    </div>
                </div>

            </div>



            <div class="content">
                <div class="license">
                    <div class="license-nav">
                        营业执照
                        <div class="btn" id="ok4">
                            未录入
                        </div>
                    </div>
                    <div class="license-content">
                        <img class="license-img" src="" id="ok5">



                        <div class="license-txt">
                            企业认证，分为企业信息认证，法人认证以及管理员授权认证，对申请使用企业动力云平台的企业进行“企业的合法性、真实性”的核实，以及“申请人是否隶属该企业且经过企业授权”的查证；通过认证的企业，方拥有企业动力云平台的所有功能操作的权限。
                        </div>
                    </div>

                    <div id="rerererre">
                        <div class="select">
                            <div class="select-item">
                                <div class="select-item-text">
                                    法人名称
                                </div>
                                <input type="text" class="layui-input select-item-input " id="artificalPerson">
                            </div>
                            <div class="select-item">
                                <div class="select-item-text">
                                    法人身份证号
                                </div>
                                <input type="number" class="layui-input select-item-input " id="idCardNo">
                            </div>
                            <!-- <div class="select-item layui-form-item">
                                <input type="checkbox" title="身份证是否长期" lay-skin="primary" id="check1">
                            </div> -->
                            <div class="select-item">
                                <div class="select-item-text">
                                    法人身份证有效期
                                </div>
                                <div class="layui-inline">
                                    <input type="text" class="layui-input" id="test1">
                                </div>
                            </div>


                            <div class="select-item">
                                <div class="select-item-text">
                                    企业证件号
                                </div>
                                <input type="number" class="layui-input select-item-input " id="No">
                            </div>
                            <!-- <div class="select-item layui-form-item">
                                <input type="checkbox" title="证件是否长期" lay-skin="primary" id="check2">
                            </div> -->
                            <div class="select-item">
                                <div class="select-item-text">
                                    企业证件有效期
                                </div>
                                <div class="layui-inline">
                                    <input type="text" class="layui-input" id="test2">
                                </div>
                            </div>

                            <div class="select-item">
                                <div class="select-item-text">
                                    联系人
                                </div>
                                <input type="text" class="layui-input select-item-input   linkman" id="linkman">
                            </div>

                            <div class="select-item">
                                <div class="select-item-text">
                                    联系人电话
                                </div>
                                <input type="text" class="layui-input select-item-input" id="telephone">
                            </div>
                            



                            <div class="select-item">
                                <div class="select-item-text">
                                    所在地区
                                </div>
                                <div class="layui-inline-sel" style="display: flex;">
                                    <select name="country" lay-filter="aihao" id='state'>
                                        <option value="0086">中国</option>
                                    </select>
                                </div>
                            </div>
                            <div class="select-item">
                                <div class="layui-inline">
                                    <div class="layui-inline-sel" style="display: flex;">

                                        <select name="province" lay-filter="province" class="province" id='province'
                                            name="s8">
                                            <option value="">省</option>
                                        </select>

                                    </div>
                                </div>
                            </div>
                            <div class="select-item">
                                <div class="layui-inline">
                                    <div class="layui-inline-sel" style="display: flex;">

                                        <select name="city" lay-filter="city" class="city" id='city' name="s9">
                                            <option value="">市</option>
                                        </select>


                                    </div>
                                </div>
                            </div>
                            <div class="select-item">
                                <div class="layui-inline">
                                    <div class="layui-inline-sel" style="display: flex;">


                                        <select name="area" lay-filter="area" class="area" id='district' name="s10">
                                            <option value="">区</option>
                                        </select>
                                    </div>
                                </div>
                            </div>

                            <div class="select-item2">
                                <div class="select-item-text">
                                    注册企业详细地址
                                </div>
                                <textarea class="select-area  dizi"></textarea>
                            </div>
                        </div>

                        <div class="upload">
                            <div class="upload-nav">
                                上传证件(图片大小不得超过2M)
                            </div>
                            <div class="upload-content" style="display: flex;">
                                <div style="margin-right: 10px;">
                                    <img src="" alt="" id="ingss">
                                    <div class="upload-btns">
                                        <div class="upload-btn" style="cursor: pointer;margin-left: 25px;" id="shang">上传
                                        </div>
                                        <!-- <div class="upload-btn" style="cursor: pointer;">删除</div> -->
                                    </div>
                                    <div class="upload-txt">营业执照</div>
                                </div>

                                <div>
                                    <img src="" alt="" id="fardden1">
                                    <div class="upload-btns">
                                        <div class="upload-btn" style="cursor: pointer;margin-left: 25px;" id="faren1">
                                            上传
                                        </div>
                                    </div>
                                    <div class="upload-txt" style="width: 110px;">法人身份证(正面)</div>
                                </div>

                                <div>
                                    <img src="" alt="" id="fardden3">
                                    <div class="upload-btns">
                                        <div class="upload-btn" style="cursor: pointer;margin-left: 25px;" id="faren3">
                                            上传
                                        </div>
                                    </div>
                                    <div class="upload-txt" style="width: 110px;">法人身份证(反面)</div>
                                </div>

                                <div>
                                    <img src="" alt="" id="fardden2">
                                    <div class="upload-btns">
                                        <div class="upload-btn" style="cursor: pointer;margin-left: 25px;" id="faren2">
                                            上传
                                        </div>
                                    </div>
                                    <div class="upload-txt" style="width: 110px;">法人身份证(手持)</div>
                                </div>

                            </div>
                        </div>
                    </div>


                </div>

                <div class="save" id="bao" style="cursor:pointer;">保存</div>
            </div>
        </div>

    </form>


</body>
<script src="../../../public/dist/layui.js" charset="utf-8"></script>
<!-- <script src="../../../js/enterprisecertification.js" charset="utf-8"></script> -->
<script src="../../../js/common/jquery.min.js"></script>
<script src="../../../js/common/api.js"></script>
<!-- <script src="../../../js/module/jquery-3.4.1.min.js"></script> -->
<script>
</script>

</html>
<script>
    layui.use(['upload', 'form', 'element', 'table', 'laydate', "layer", "laydate", "util"], function () {
        var $ = layui.jquery,
            table = layui.table,
            layer = layui.layer,
            laydate = layui.laydate,
            util = layui.util,
            form = layui.form,
            element = layui.element,
            upload = layui.upload;
        var laydate = layui.laydate;
        var obj1 = {},
            obj2 = {};

        laydate.render({
            elem: '#youx' //指定元素
        });
        laydate.render({
            elem: '#test1', //指定元素
            type: 'date'
        });
        laydate.render({
            elem: '#test2', //指定元素
            type: 'date'
        });



        //判断是否认证
        handleAjax("coa/getCoBusinessInfo", obj1, "get", "utf-8").done(function (resp) {
            console.log(resp)
            if (resp.code == 10000) {

                if (resp.list[0].linkman != null && resp.list[0].businessNo != null) {
                    // $(".header-icon>i").attr("class", "layui-icon layui-icon-ok-circle");
                    $("#rerererre").css("display", "none");
                    $("#ok5").attr("src", resp.list[0].businessNo);
                } else {
                    // $(".header-icon>i").attr("class", "layui-icon layui-icon-circle");
                    $("#rerererre").css("display", "block");
                    // layui-icon-ok-circle
                }
            }
            return
        }).fail(function (err) {
            console.log(err)
        });


        //省市区三级联动
        getProvince();
        function getProvince(e) {
            handleAjax('enterprise/getProvincecity', { parentid: e }, "GET").done(function (resp) {


                $.each(resp.list, function (index, item) {
                    $('.province').append(new Option(item.fullName, item.code)); // 下拉菜单里添加元素
                });
                layui.form.render("select");
                return
            }).fail(function (err) {
                console.log(err)

            });
        }
        function getCity(e) {
            handleAjax('enterprise/getProvincecity', { parentid: e }, "GET").done(function (resp) {
                $.each(resp.list, function (index, item) {
                    $('.city').append(new Option(item.fullName, item.code)); // 下拉菜单里添加元素
                });
                layui.form.render("select");
                return
            }).fail(function (err) {
                console.log(err)

            });
        }
        function getArea(e) {
            handleAjax('enterprise/getProvincecity', { parentid: e }, "GET").done(function (resp) {


                $.each(resp.list, function (index, item) {
                    $('.area').append(new Option(item.fullName, item.code)); // 下拉菜单里添加元素
                });
                layui.form.render("select");
                return
            }).fail(function (err) {
                console.log(err)

            });
        }
        form.on('select(province)', function (data) {
            console.log(data.value); //得到被选中的值
            document.querySelector('.city').innerHTML = '<option value="">市</option>';
            document.querySelector('.area').innerHTML = '<option value="">区</option>';
            getCity(data.value);
        });
        form.on('select(city)', function (data) {
            console.log(data.value); //得到被选中的值
            document.querySelector('.area').innerHTML = '<option value="">区</option>';
            getArea(data.value);
        });




        //上传图片营业
        upload.render({
            elem: '#shang',
            url: base + "common/upload",
            accept: 'file',
            field: "file",
            headers: { Authorization: 'Bearer' + ' ' + sessions },
            done: function (res) {
                console.log(res);
                var ss = res.list[0];
                layer.msg(res.message);
                $("#ingss").attr("src", ss);
                $("#ok1").text("已录入");
                $("#ok4").text("已录入");
                $("#ok5").attr("src", ss);


            },
            error: function (res) {
                layer.msg(res.message);
            }
        });



        //上传图片|法人正面
        var uploadInst = upload.render({
            elem: '#faren1',
            url: base + "common/upload",
            accept: 'file',
            field: "file",
            headers: { Authorization: 'Bearer' + ' ' + sessions },
            done: function (res) {
                console.log(res);
                var ss = res.list[0];
                layer.msg(res.message);
                $("#fardden1").attr("src", ss);
                // $("#ok2").text("已录入");

                sfz()

            },
            error: function (res) {
                layer.msg(res.message);
            }
        });

        //上传图片|法人反面
        var uploadInst = upload.render({
            elem: '#faren3',
            url: base + "common/upload",
            accept: 'file',
            field: "file",
            headers: { Authorization: 'Bearer' + ' ' + sessions },
            done: function (res) {
                console.log(res);
                var ss = res.list[0];
                layer.msg(res.message);
                $("#fardden3").attr("src", ss);

                sfz()


            },
            error: function (res) {
                layer.msg(res.message);
            }
        });

        //上传图片|手持
        var uploadInst = upload.render({
            elem: '#faren2',
            url: base + "common/upload",
            accept: 'file',
            field: "file",
            headers: { Authorization: 'Bearer' + ' ' + sessions },
            done: function (res) {
                console.log(res);
                var ss = res.list[0];
                layer.msg(res.message);
                $("#fardden2").attr("src", ss);

                sfz()


            },
            error: function (res) {
                layer.msg(res.message);
            }
        });

        function sfz() {
            if ($("#fardden1").attr("src") != '' && $("#fardden2").attr("src") != '' && $("#fardden3").attr("src") != '') {
                $("#ok2").text("已录入");
            }
        }






        $("#bao").click(function () {
            if ($("#artificalPerson").val() == "") {
                layer.msg("请输入联系人");
                return
            }
            if ($("#idCardNo").val() == "") {
                layer.msg("请输入联系人");
                return
            }

            if ($("#linkman").val() == "") {
                layer.msg("请输入联系人");
                return
            }
            if ($("#telephone").val() == "") {
                layer.msg("请输入联系人电话");
                return
            }
            if ($("#youx").val() == "") {
                layer.msg("请选择证件有效期");
                return
            }

            if ($("#city").val() == null) {
                layer.msg("请选择市区");
                return
            }

            if ($("#district").val() == null) {
                layer.msg("请选择区域");
                return
            }


            if ($(".dizi").val() == null) {
                layer.msg("请输入详细地址");
                return
            }

            if ($('#ingss').val() == null) {
                layer.msg("请上传营业执照");
                return
            }
            obj = JSON.stringify(this.obj)
            console.log(obj)

            obj1.city = $('#city').val();
            obj1.custAdd = $('.dizi').val();
            obj1.district = $('#district').val();
            obj1.isLongTime = true;
            obj1.licenseImage = $("#ingss").attr("src");
            obj1.linkman = $('#linkman').val();
            obj1.state = $('#province').val();
            obj1.taxRegister = $('#No').val();
            obj1.telephone = $('#telephone').val();
            obj1.validDate = $('#test2').val();


            obj2.artificalPerson = $('#artificalPerson').val();
            obj2.idCardImageOne = $("#fardden1").attr("src");
            obj2.idCardImageThree = $("#fardden2").attr("src");
            obj2.idCardImageTwo = $("#fardden3").attr("src");
            obj2.idCardIsLongTime = true;
            obj2.idCardNo = $('#idCardNo').val();
            obj2.idCardValidDate = $('#test1').val();

            console.log(obj1)
            console.log(obj2)


            handleAjax("coa/addCoBusinessInfo2", obj2, "POST").done(function (resp) {
                if (resp.code == 10000) {
                    handleAjax("coa/addCoBusinessInfo1", obj1, "POST").done(function (resp) {
                        if (resp.code == 10000) {
                            $("#ok3").text("已录入");
                            layer.msg('操作成功', {
                                icon: 1,
                                time: 1000
                            });
                            setTimeout(function () {
                                window.location.reload();
                            }, 1500)
                            return
                        }
                    })
                }
            }).fail(function (err) {
                console.log(err)
            });

            // Theoldcuiway('coa/addCoBusinessInfo', {
            //     type: "fsfsfssfuieinxhbe",
            //     context: obj,
            //     keyword: "objniukey"
            // }, "POST").done(function (resp) {
            //     console.log(resp)
            //     if (resp.code == 10000) {
            //         layer.msg('操作成功', {
            //             icon: 1,
            //             time: 1000
            //         });
            //         setTimeout(function () {
            //             window.location.reload();
            //         }, 1500)
            //         return
            //     }
            //     return
            // }).fail(function (err) {
            //     console.log(err)
            // });
        })
    })

</script>